package com.ctl.utils;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;

/**
 * <p>Title: SnowflakeIdUtils</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2019</p>
 * <p>Company: www.ctl.com</p>
 *          <dependency>
 *             <groupId>cn.hutool</groupId>
 *             <artifactId>hutool-core</artifactId>
 *             <version>5.8.15</version>
 *         </dependency>
 * @author ctl
 * @version 1.1
 * @date 2023-06-07 16:01
 */
public class SnowflakeIdUtils {
    // 传入机器id和数据中心id，数据范围为：0~31
    private static Snowflake snowflake = IdUtil.getSnowflake(1L, 1L);

    public static long nextId() {
        return snowflake.nextId();
    }

    public static void main(String[] args) {
        // 传入机器id和数据中心id，数据范围为：0~31
        System.out.println(SnowflakeIdUtils.nextId());
        Snowflake sf = IdUtil.getSnowflake(1L, 1L);
        sf = IdUtil.getSnowflake(1L, 1L);
        System.out.println(sf.nextId());
    }
}
